using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace KD.Sms.Controls
{
    public class LiveVideo : UserControl
    {
        public delegate void MyDebugInfo(string str);

        public enum DashStyleType
        {
            //实线
            Custom,
            //粗点虚线
            Dash,
            //密点虚线
            DashDot,
            //长短虚线
            DashDotDot
        }

        public delegate void Changed(int Xbegin, int Ybegin, int Xend, int Yend);

        private IContainer components = null;

        private PictureBox pictureBox;

        private System.Windows.Forms.Timer timer1;

        private NET_SDK.NET_DVR_JPEGPARA lpJpegPara = default(NET_SDK.NET_DVR_JPEGPARA);

        private int mychanelA = 0;

        private bool m_bInitSDK = false;

        private uint iLastErr = 0u;

        private int m_lUserID = -1;

        private int m_lRealHandle = -1;

        private int i = 0;

        private uint dwAChanTotalNum = 0u;

        private int[] iIPDevID = new int[96];

        private int[] iChannelNum = new int[96];

        private static int x = 0;

        private static int y = 30;

        private static int fx = 100;

        private static int fy = 100;

        private static int r = 30;

        private static int mycount = 0;

        private static string mystr = null;

        public string mystrr;

        private bool aa;

        private NET_SDK.DRAWFUN mydrawfun;

        public NET_SDK.NET_DVR_DEVICEINFO_V30 DeviceInfo;

        public NET_SDK.NET_DVR_IPPARACFG_V40 m_struIpParaCfgV40;

        public NET_SDK.NET_DVR_STREAM_MODE m_struStreamMode;

        public NET_SDK.NET_DVR_IPCHANINFO m_struChanInfo;

        public NET_SDK.NET_DVR_IPCHANINFO_V40 m_struChanInfoV40;

        private PlayCtrl.DECCBFUN m_fDisplayFun = null;

        private Bitmap bmp2 = new Bitmap(320, 240);

        private Bitmap bmp1 = new Bitmap(320, 240);

        public int _VideoProperty_Brightness;

        public int _VideoProperty_Contrast;

        public int _VideoProperty_Saturation;

        public int _VideoProperty_Hue;

        public int _VideoProperty_Sharpness;

        private static float emsize = 1f;

        public int disc = 0;

        public static int z_height = 12;

        private static int z_width = 1;

        public int zz_width = 4;

        public int disc11 = 0;

        public bool E_Enable;

        public bool TKORHK = false;

        public bool TKORHKed = false;

        private bool myisshowlajin = false;

        private bool myisshow18 = false;

        private static int x0 = 0;

        private static int y0 = 0;

        private static int x1 = 0;

        private static int y1 = 0;

        private int x0_old = 0;

        private static int y0_old = 0;

        private static int x1_old = 0;

        private static int y1_old = 0;

        private static int x10 = 0;

        private static int y10 = 0;

        private static int x11 = 0;

        private static int y11 = 0;


        public int[] XLAJIN = new int[10]
        {
            -11,
            -11,
            -11,
            -11,
            -11,
            -11,
            -11,
            -11,
            -11,
            -11
        };

        private string strrr;

        private string bmppath = "";

        private bool falg = false;

        private static int[] rx = new int[20];

        private static int[] ry = new int[20];

        private static Color[] rc = new Color[20];

        private static int myrr = 0;

        private static Color _mycolora = Color.Red;

        private static Color _mycolorb = Color.Red;
        private Button button1;
        private static DashStyleType _myDashStyleType = DashStyleType.Dash;

        [Browsable(true)]
        [Category("自定义")]
        [TypeConverter(typeof(int))]
        [Description("画点的R")]
        public int myR
        {
            get
            {
                return myrr;
            }
            set
            {
                myrr = value;
            }
        }

        [Description("时间字的颜色")]
        [Category("自定义")]
        [TypeConverter(typeof(KnownColor))]
        [Browsable(true)]
        public Color E_CustomColorA
        {
            get
            {
                return _mycolora;
            }
            set
            {
                _mycolora = value;
            }
        }

        [Browsable(true)]
        [TypeConverter(typeof(KnownColor))]
        [Description("画框的颜色")]
        [Category("自定义")]
        public Color E_CustomColorB
        {
            get
            {
                return _mycolorb;
            }
            set
            {
                _mycolorb = value;
            }
        }

        [Browsable(true)]
        [Category("自定义")]
        [Description("画框的线型")]
        public DashStyleType E_DashStyleType
        {
            get
            {
                return _myDashStyleType;
            }
            set
            {
                _myDashStyleType = value;
            }
        }

        public event Changed DoDrawComplete;

        protected override void Dispose(bool disposing)
        {
            if (disposing && components != null)
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.pictureBox = new System.Windows.Forms.PictureBox();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.button1 = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
            this.SuspendLayout();
            // 
            // pictureBox
            // 
            this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.pictureBox.Location = new System.Drawing.Point(3, 3);
            this.pictureBox.Name = "pictureBox";
            this.pictureBox.Size = new System.Drawing.Size(215, 121);
            this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.pictureBox.TabIndex = 16;
            this.pictureBox.TabStop = false;
            this.pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseDown);
            this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseMove);
            this.pictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseUp);
            // 
            // timer1
            // 
            this.timer1.Enabled = true;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(82, 544);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 17;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // LiveVideo
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.pictureBox);
            this.Controls.Add(this.button1);
            this.Name = "LiveVideo";
            this.Size = new System.Drawing.Size(248, 157);
            this.Load += new System.EventHandler(this.myVideo_Load);
            this.Resize += new System.EventHandler(this.myVideo_Resize);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
            this.ResumeLayout(false);

        }

        public LiveVideo()
        {
            InitializeComponent();
        }

        private int myjishanX(int adgg)
        {
            int num = 0;
            return adgg * 1000 / pictureBox.Width;
        }

        private int myjishanY(int adgg)
        {
            int num = 0;
            return adgg * 1000 / pictureBox.Height;
        }

        private void cbDrawFun(int lRealHandle, IntPtr hDC, uint dwUser)
        {
            Point[] array = new Point[5];
            array[0].X = x10;
            array[0].Y = y10;
            array[1].X = x10;
            array[1].Y = y11;
            array[2].X = x11;
            array[2].Y = y11;
            array[3].X = x11;
            array[3].Y = y10;
            array[4].X = x10;
            array[4].Y = y10;
            Point p = new Point(x, y);
            Font font = new Font("黑体", emsize, FontStyle.Bold);
            Brush brush = new SolidBrush(_mycolora);
            Pen pen = new Pen(_mycolorb, z_width);
            pen.DashStyle = (DashStyle)_myDashStyleType;
            Graphics graphics = Graphics.FromHdc(hDC);
            graphics.DrawLines(pen, array);
            Point[] array2 = new Point[20];
            array2[0].X = XLAJIN[0] * pictureBox.Width / 1000;
            array2[0].Y = y10;
            array2[1].X = XLAJIN[0] * pictureBox.Width / 1000;
            array2[1].Y = y11;
            array2[2].X = XLAJIN[1] * pictureBox.Width / 1000;
            array2[2].Y = y10;
            array2[3].X = XLAJIN[1] * pictureBox.Width / 1000;
            array2[3].Y = y11;
            array2[4].X = XLAJIN[2] * pictureBox.Width / 1000;
            array2[4].Y = y10;
            array2[5].X = XLAJIN[2] * pictureBox.Width / 1000;
            array2[5].Y = y11;
            array2[6].X = XLAJIN[3] * pictureBox.Width / 1000;
            array2[6].Y = y10;
            array2[7].X = XLAJIN[3] * pictureBox.Width / 1000;
            array2[7].Y = y11;
            array2[8].X = XLAJIN[4] * pictureBox.Width / 1000;
            array2[8].Y = y10;
            array2[9].X = XLAJIN[4] * pictureBox.Width / 1000;
            array2[9].Y = y11;
            array2[10].X = XLAJIN[5] * pictureBox.Width / 1000;
            array2[10].Y = y10;
            array2[11].X = XLAJIN[5] * pictureBox.Width / 1000;
            array2[11].Y = y11;
            array2[12].X = XLAJIN[6] * pictureBox.Width / 1000;
            array2[12].Y = y10;
            array2[13].X = XLAJIN[6] * pictureBox.Width / 1000;
            array2[13].Y = y11;
            array2[14].X = XLAJIN[7] * pictureBox.Width / 1000;
            array2[14].Y = y10;
            array2[15].X = XLAJIN[7] * pictureBox.Width / 1000;
            array2[15].Y = y11;
            array2[16].X = XLAJIN[8] * pictureBox.Width / 1000;
            array2[16].Y = y10;
            array2[17].X = XLAJIN[8] * pictureBox.Width / 1000;
            array2[17].Y = y11;
            array2[18].X = XLAJIN[9] * pictureBox.Width / 1000;
            array2[18].Y = y10;
            array2[19].X = XLAJIN[9] * pictureBox.Width / 1000;
            array2[19].Y = y11;
            if (myisshowlajin)
            {
                graphics.DrawLine(pen, array2[0], array2[1]);
                graphics.DrawLine(pen, array2[2], array2[3]);
                graphics.DrawLine(pen, array2[4], array2[5]);
                graphics.DrawLine(pen, array2[6], array2[7]);
                graphics.DrawLine(pen, array2[8], array2[9]);
                graphics.DrawLine(pen, array2[10], array2[11]);
                graphics.DrawLine(pen, array2[12], array2[13]);
                graphics.DrawLine(pen, array2[14], array2[15]);
                graphics.DrawLine(pen, array2[16], array2[17]);
                graphics.DrawLine(pen, array2[18], array2[19]);
            }
            Pen pen2 = new Pen(Color.AliceBlue, 1f);
            pen2.DashStyle = DashStyle.Dash;
            int num = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;
            int num15 = 0;
            int num16 = 0;
            int num29 = x10;
            int num30 = x11;
            int num31 = y10;
            int num32 = y11;
            double d = num29 + (num30 - num29) / 6;
            double d2 = num29 + 2 * (num30 - num29) / 6;
            double d3 = num29 + 3 * (num30 - num29) / 6;
            double d4 = num29 + 4 * (num30 - num29) / 6;
            double d5 = num29 + 5 * (num30 - num29) / 6;
            double d6 = num31 + (num32 - num31) / 3;
            double d7 = num31 + 2 * (num32 - num31) / 3;
            num = Convert.ToInt32(Math.Floor(d));
            num2 = Convert.ToInt32(Math.Floor(d2));
            num3 = Convert.ToInt32(Math.Floor(d3));
            num4 = Convert.ToInt32(Math.Floor(d4));
            num5 = Convert.ToInt32(Math.Floor(d5));
            num15 = Convert.ToInt32(Math.Floor(d6));
            num16 = Convert.ToInt32(Math.Floor(d7));
            Point[] array3 = new Point[14];
            array3[0].X = num;
            array3[0].Y = num31;
            array3[2].X = num2;
            array3[2].Y = num31;
            array3[4].X = num3;
            array3[4].Y = num31;
            array3[6].X = num4;
            array3[6].Y = num31;
            array3[8].X = num5;
            array3[8].Y = num31;
            array3[1].X = num;
            array3[1].Y = num32;
            array3[3].X = num2;
            array3[3].Y = num32;
            array3[5].X = num3;
            array3[5].Y = num32;
            array3[7].X = num4;
            array3[7].Y = num32;
            array3[9].X = num5;
            array3[9].Y = num32;
            array3[10].X = num29;
            array3[10].Y = num15;
            array3[12].X = num29;
            array3[12].Y = num16;
            array3[11].X = num30;
            array3[11].Y = num15;
            array3[13].X = num30;
            array3[13].Y = num16;
            if (myisshow18)
            {
                graphics.DrawLine(pen2, array3[0], array3[1]);
                graphics.DrawLine(pen2, array3[2], array3[3]);
                graphics.DrawLine(pen2, array3[4], array3[5]);
                graphics.DrawLine(pen2, array3[6], array3[7]);
                graphics.DrawLine(pen2, array3[8], array3[9]);
                graphics.DrawLine(pen2, array3[10], array3[11]);
                graphics.DrawLine(pen2, array3[12], array3[13]);
            }
            if (mystr != null)
            {
                graphics.DrawString(mystr, font, brush, p);
                mycount++;
            }
            if (mycount > 30)
            {
                mystr = null;
                mycount = 0;
            }
            graphics.SmoothingMode = SmoothingMode.HighQuality;
            for (int i = 0; i < 20; i++)
            {
                graphics.FillEllipse(new SolidBrush(rc[i]), new Rectangle(rx[i] - r / 2, ry[i] - r / 2, r, r));
            }
        }

        private void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (E_Enable)
            {
                if (TKORHK)
                {
                    x0 = e.X;
                    y0 = e.Y;
                    x1 = e.X;
                    y1 = e.Y;
                }
                else
                {
                    x10 = e.X;
                    y10 = e.Y;
                    x11 = e.X;
                    y11 = e.Y;
                }
                falg = true;
            }
        }

        private void pictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (TKORHK && E_Enable && TKORHKed)
            {
                Cursor = Cursors.Hand;
            }
            else
            {
                Cursor = Cursors.Arrow;
            }
            if (!E_Enable)
            {
                return;
            }
            if (!TKORHK)
            {
                if (falg)
                {
                    x1 = e.X;
                    y1 = e.Y;
                    x11 = e.X;
                    y11 = e.Y;
                }
            }
            else if (falg && TKORHKed)
            {
                x10 = x0_old + e.X - x0;
                y10 = y0_old + e.Y - y0;
                x11 = x1_old + e.X - x0;
                y11 = y1_old + e.Y - y0;
            }
        }

        private void pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            falg = false;
            if (!E_Enable || (!TKORHKed && TKORHK))
            {
                return;
            }
            string text = "";
            text = (TKORHK ? "请您确认是否拖框完成" : "请您确认是否画框完成");
            if (MessageBox.Show(text, "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                TKORHKed = false;
                x0_old = 0;
                y0_old = 0;
                x1_old = 0;
                y1_old = 0;
                if (this.DoDrawComplete == null)
                {
                    return;
                }
                if (x10 - x11 < 0)
                {
                    if (y10 - y11 < 0)
                    {
                        this.DoDrawComplete(myjishanX(x10), myjishanY(y10), myjishanX(x11), myjishanY(y11));
                    }
                    else
                    {
                        this.DoDrawComplete(myjishanX(x10), myjishanY(y11), myjishanX(x11), myjishanY(y10));
                    }
                }
                else if (y10 - y11 < 0)
                {
                    this.DoDrawComplete(myjishanX(x11), myjishanY(y10), myjishanX(x10), myjishanY(y11));
                }
                else
                {
                    this.DoDrawComplete(myjishanX(x11), myjishanY(y11), myjishanX(x10), myjishanY(y10));
                }
            }
            else if (!TKORHK)
            {
                x10 = 0;
                y10 = 0;
                x11 = 0;
                y11 = 0;
            }
            else
            {
                x0_old = x10;
                y0_old = y10;
                x1_old = x11;
                y1_old = y11;
            }
        }

        public void CHANGcolorA(string MYCOLOR)
        {
            string[] array = MYCOLOR.Split(',');
            _mycolora = Color.FromArgb(Convert.ToInt16(array[0]), Convert.ToInt16(array[1]), Convert.ToInt16(array[2]));
        }

        public void CHANGcolorB(string MYCOLOR)
        {
            string[] array = MYCOLOR.Split(',');
            _mycolorb = Color.FromArgb(Convert.ToInt16(array[0]), Convert.ToInt16(array[1]), Convert.ToInt16(array[2]));
        }

        public void CHANGDashwith(int MYwith)
        {
            if (MYwith <= 5)
            {
                z_width = MYwith;
            }
        }

        public void CHANGDashStyleType(int MYDashStyleType)
        {
            if (MYDashStyleType <= 5)
            {
                _myDashStyleType = (DashStyleType)MYDashStyleType;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="xx1"></param>
        /// <param name="yy1"></param>
        /// <param name="xx2"></param>
        /// <param name="yy2"></param>
        /// <param name="ishand"></param>
        /// <param name="isshowlajin"></param>
        /// <param name="isshow18"></param>
        public void setTKvalues(int xx1, int yy1, int xx2, int yy2, bool ishand, bool isshowlajin, bool isshow18)
        {
            myisshowlajin = isshowlajin;
            myisshow18 = isshow18;
            if (!TKORHK || !E_Enable)
            {
                return;
            }
            if (xx1 < 0 || xx1 > 1000)
            {
                xx1 = 0;
                return;
            }
            if (xx2 < 0 || xx2 > 1000)
            {
                xx2 = 0;
                return;
            }
            if (yy1 < 0 || yy1 > 1000)
            {
                yy1 = 0;
                return;
            }
            if (yy2 < 0 || yy2 > 1000)
            {
                yy2 = 0;
                return;
            }
            x10 = pictureBox.Width * xx1 / 1000;
            y10 = pictureBox.Height * yy1 / 1000;
            x11 = pictureBox.Width * xx2 / 1000;
            y11 = pictureBox.Height * yy2 / 1000;
            x0_old = x10;
            y0_old = y10;
            x1_old = x11;
            y1_old = y11;
            if (ishand)
            {
                TKORHKed = true;
            }
        }

        /// <summary>
        /// 截图
        /// </summary>
        /// <param name="_bmppath"></param>
        /// <param name="_str"></param>
        /// <param name="isshowlanjin"></param>
        /// <param name="isshow18"></param>
        /// <returns></returns>
        public uint DoCatchImage(string _bmppath, string _str, bool isshowlanjin, bool isshow18)
        {
            FileStream fileStream = null;
            Image image = new Bitmap(320, 240);
            Image image2 = null;
            uint num = 0u;
            bmppath = _bmppath;
            mystr = _str;
            strrr = _str;
            int lChannel = mychanelA;
            lpJpegPara.wPicQuality = 2;
            lpJpegPara.wPicSize = 255;
            uint num2 = 400000u;
            byte[] array = new byte[num2];
            uint lpSizeReturned = 0u;
            try
            {
                File.Delete(_bmppath);
            }
            catch
            {
            }
            int num4;
            if (!NET_SDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, ref lpJpegPara, array, num2, ref lpSizeReturned))
            {
                if (!NET_SDK.NET_DVR_CapturePicture(m_lRealHandle, _bmppath))
                {
                    num = NET_SDK.NET_DVR_GetLastError();
                    if (num != 0)
                    {
                        return num;
                    }
                    for (num4 = 0; num4 < 10; num4++, num4++)
                    {
                        try
                        {
                            fileStream = File.OpenRead(_bmppath);
                        }
                        catch (Exception)
                        {
                            Thread.Sleep(300);
                            continue;
                        }
                        break;
                    }
                    int num5 = 0;
                    num5 = (int)fileStream.Length;
                    byte[] buffer = new byte[num5];
                    fileStream.Read(buffer, 0, num5);
                    MemoryStream memoryStream = new MemoryStream(buffer);
                    image2 = Image.FromStream(memoryStream);
                    memoryStream.Flush();
                    Graphics graphics = Graphics.FromImage(image);
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.DrawImage(image2, new Rectangle(0, 0, 320, 240));
                }
                else
                {
                    for (num4 = 0; num4 < 10; num4++, num4++)
                    {
                        try
                        {
                            fileStream = File.OpenRead(_bmppath);
                        }
                        catch (Exception)
                        {
                            Thread.Sleep(300);
                            continue;
                        }
                        break;
                    }
                    int num5 = 0;
                    num5 = (int)fileStream.Length;
                    byte[] buffer = new byte[num5];
                    fileStream.Read(buffer, 0, num5);
                    fileStream.Close();
                    MemoryStream memoryStream = new MemoryStream(buffer);
                    image2 = Image.FromStream(memoryStream);
                    memoryStream.Flush();
                    Graphics graphics = Graphics.FromImage(image);
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.DrawImage(image2, new Rectangle(0, 0, 320, 240));
                }
            }
            else
            {
                MemoryStream memoryStream = new MemoryStream(array);
                image2 = Image.FromStream(memoryStream);
                memoryStream.Flush();
                Graphics graphics = Graphics.FromImage(image);
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.DrawImage(image2, new Rectangle(0, 0, 320, 240));
            }
            double num6 = 1.00001;
            double num7 = 1.00001;
            num6 = Math.Round(Convert.ToDouble(image.Width) / Convert.ToDouble(pictureBox.Width), 5);
            num7 = Math.Round(Convert.ToDouble(image.Height) / Convert.ToDouble(pictureBox.Height), 5);
            Point[] array2 = new Point[5];
            array2[0].X = Convert.ToInt32(Math.Floor((double)x10 * num6));
            array2[0].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array2[1].X = Convert.ToInt32(Math.Floor((double)x10 * num6));
            array2[1].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array2[2].X = Convert.ToInt32(Math.Floor((double)x11 * num6));
            array2[2].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array2[3].X = Convert.ToInt32(Math.Floor((double)x11 * num6));
            array2[3].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array2[4].X = Convert.ToInt32(Math.Floor((double)x10 * num6));
            array2[4].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            Point p = new Point(x, y);
            Font font = new Font("黑体", emsize, FontStyle.Bold);
            Brush brush = new SolidBrush(_mycolora);
            Pen pen = new Pen(_mycolorb, z_width);
            pen.DashStyle = (DashStyle)_myDashStyleType;
            Graphics graphics2 = Graphics.FromImage(image);
            graphics2.DrawLines(pen, array2);
            Point[] array3 = new Point[20];
            array3[0].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[0] * pictureBox.Width / 1000) * num6));
            array3[0].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[1].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[0] * pictureBox.Width / 1000) * num6));
            array3[1].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[2].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[1] * pictureBox.Width / 1000) * num6));
            array3[2].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[3].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[1] * pictureBox.Width / 1000) * num6));
            array3[3].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[4].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[2] * pictureBox.Width / 1000) * num6));
            array3[4].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[5].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[2] * pictureBox.Width / 1000) * num6));
            array3[5].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[6].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[3] * pictureBox.Width / 1000) * num6));
            array3[6].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[7].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[3] * pictureBox.Width / 1000) * num6));
            array3[7].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[8].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[4] * pictureBox.Width / 1000) * num6));
            array3[8].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[9].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[4] * pictureBox.Width / 1000) * num6));
            array3[9].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[10].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[5] * pictureBox.Width / 1000) * num6));
            array3[10].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[11].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[5] * pictureBox.Width / 1000) * num6));
            array3[11].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[12].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[6] * pictureBox.Width / 1000) * num6));
            array3[12].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[13].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[6] * pictureBox.Width / 1000) * num6));
            array3[13].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[14].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[7] * pictureBox.Width / 1000) * num6));
            array3[14].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[15].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[7] * pictureBox.Width / 1000) * num6));
            array3[15].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[16].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[8] * pictureBox.Width / 1000) * num6));
            array3[16].Y = Convert.ToInt32(Math.Floor((double)(y10 * pictureBox.Height / 1000) * num7));
            array3[17].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[8] * pictureBox.Width / 1000) * num6));
            array3[17].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[18].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[9] * pictureBox.Width / 1000) * num6));
            array3[18].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[19].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[9] * pictureBox.Width / 1000) * num6));
            array3[19].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            if (isshowlanjin)
            {
                graphics2.DrawLine(pen, array3[0], array3[1]);
                graphics2.DrawLine(pen, array3[2], array3[3]);
                graphics2.DrawLine(pen, array3[4], array3[5]);
                graphics2.DrawLine(pen, array3[6], array3[7]);
                graphics2.DrawLine(pen, array3[8], array3[9]);
                graphics2.DrawLine(pen, array3[10], array3[11]);
                graphics2.DrawLine(pen, array3[12], array3[13]);
                graphics2.DrawLine(pen, array3[14], array3[15]);
                graphics2.DrawLine(pen, array3[16], array3[17]);
                graphics2.DrawLine(pen, array3[18], array3[19]);
            }
            Pen pen2 = new Pen(Color.AliceBlue, 1f);
            pen2.DashStyle = DashStyle.Dash;
            int num8 = 0;
            int num9 = 0;
            int num10 = 0;
            int num11 = 0;
            int num12 = 0;
            int num13 = 0;
            int num14 = 0;
            int num15 = 0;
            int num16 = 0;
            int num17 = 0;
            int num18 = 0;
            int num19 = 0;
            int num20 = 0;
            int num21 = 0;
            int num22 = 0;
            int num23 = 0;
            int num24 = 0;
            int num25 = 0;
            int num26 = 0;
            int num27 = 0;
            int num28 = 0;
            int num29 = 0;
            int num30 = 0;
            int num31 = Convert.ToInt32(Math.Floor((double)x10 * num6));
            int num32 = Convert.ToInt32(Math.Floor((double)x11 * num6));
            int num33 = Convert.ToInt32(Math.Floor((double)y10 * num7));
            int num34 = Convert.ToInt32(Math.Floor((double)y11 * num7));
            double d = num31 + (num32 - num31) / 6;
            double d2 = num31 + 2 * (num32 - num31) / 6;
            double d3 = num31 + 3 * (num32 - num31) / 6;
            double d4 = num31 + 4 * (num32 - num31) / 6;
            double d5 = num31 + 5 * (num32 - num31) / 6;
            double d6 = num33 + (num34 - num33) / 3;
            double d7 = num33 + 2 * (num34 - num33) / 3;
            num8 = Convert.ToInt32(Math.Floor(d));
            num9 = Convert.ToInt32(Math.Floor(d2));
            num10 = Convert.ToInt32(Math.Floor(d3));
            num11 = Convert.ToInt32(Math.Floor(d4));
            num12 = Convert.ToInt32(Math.Floor(d5));
            num22 = Convert.ToInt32(Math.Floor(d6));
            num23 = Convert.ToInt32(Math.Floor(d7));
            Point[] array4 = new Point[14];
            array4[0].X = num8;
            array4[0].Y = num33;
            array4[2].X = num9;
            array4[2].Y = num33;
            array4[4].X = num10;
            array4[4].Y = num33;
            array4[6].X = num11;
            array4[6].Y = num33;
            array4[8].X = num12;
            array4[8].Y = num33;
            array4[1].X = num8;
            array4[1].Y = num34;
            array4[3].X = num9;
            array4[3].Y = num34;
            array4[5].X = num10;
            array4[5].Y = num34;
            array4[7].X = num11;
            array4[7].Y = num34;
            array4[9].X = num12;
            array4[9].Y = num34;
            array4[10].X = num31;
            array4[10].Y = num22;
            array4[12].X = num31;
            array4[12].Y = num23;
            array4[11].X = num32;
            array4[11].Y = num22;
            array4[13].X = num32;
            array4[13].Y = num23;
            if (isshow18)
            {
                graphics2.DrawLine(pen2, array4[0], array4[1]);
                graphics2.DrawLine(pen2, array4[2], array4[3]);
                graphics2.DrawLine(pen2, array4[4], array4[5]);
                graphics2.DrawLine(pen2, array4[6], array4[7]);
                graphics2.DrawLine(pen2, array4[8], array4[9]);
                graphics2.DrawLine(pen2, array4[10], array4[11]);
                graphics2.DrawLine(pen2, array4[12], array4[13]);
            }
            if (mystr != null)
            {
                graphics2.DrawString(_str, font, brush, p);
                mycount++;
            }
            if (mycount > 30)
            {
                mystr = null;
                mycount = 0;
            }
            graphics2.SmoothingMode = SmoothingMode.HighQuality;
            for (num4 = 0; num4 < 20; num4++)
            {
                graphics2.FillEllipse(new SolidBrush(rc[num4]), new Rectangle(Convert.ToInt32(Math.Floor((double)rx[num4] * num6)) - Convert.ToInt32(Math.Floor((double)r * num6)) / 2, Convert.ToInt32(Math.Floor((double)ry[num4] * num7)) - Convert.ToInt32(Math.Floor((double)r * num6)) / 2, Convert.ToInt32(Math.Floor((double)r * num6)), Convert.ToInt32(Math.Floor((double)r * num6))));
            }
            for (num4 = 0; num4 < 10; num4++, num4++)
            {
                try
                {
                    image.Save(_bmppath);
                }
                catch (Exception)
                {
                    Thread.Sleep(300);
                    continue;
                }
                break;
            }
            image.Dispose();
            return num;
        }

        public uint DoCatchImage(ref Image _bitmap, string _str, bool isshowlajin, bool isshow18)
        {
            FileStream fileStream = null;
            Image image = new Bitmap(1024, 768);
            Image image2 = null;
            uint num = 0u;
            mystr = _str;
            strrr = _str;
            int lChannel = mychanelA;
            lpJpegPara.wPicQuality = 2;
            lpJpegPara.wPicSize = 255;
            uint num2 = 400000u;
            byte[] array = new byte[num2];
            uint lpSizeReturned = 0u;
            try
            {
                File.Delete("c:\\test.jpg");
            }
            catch
            {
            }
            if (!NET_SDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, ref lpJpegPara, array, num2, ref lpSizeReturned))
            {
                if (!NET_SDK.NET_DVR_CapturePicture(m_lRealHandle, "c:\\test.jpg"))
                {
                    num = NET_SDK.NET_DVR_GetLastError();
                    if (num != 0)
                    {
                        return num;
                    }
                    int num3 = 0;
                    int num4;
                    for (num4 = 0; num4 < 10; num4++, num4++)
                    {
                        try
                        {
                            fileStream = File.OpenRead("c:\\test.jpg");
                        }
                        catch (Exception)
                        {
                            Thread.Sleep(300);
                            continue;
                        }
                        break;
                    }
                    int num5 = 0;
                    num5 = (int)fileStream.Length;
                    byte[] buffer = new byte[num5];
                    fileStream.Read(buffer, 0, num5);
                    MemoryStream memoryStream = new MemoryStream(buffer);
                    image2 = Image.FromStream(memoryStream);
                    memoryStream.Flush();
                    Graphics graphics = Graphics.FromImage(image);
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.DrawImage(image2, new Rectangle(0, 0, image.Width, image.Height));
                }
                else
                {
                    int num4;
                    for (num4 = 0; num4 < 10; num4++, num4++)
                    {
                        try
                        {
                            fileStream = File.OpenRead("c:\\test.jpg");
                        }
                        catch (Exception)
                        {
                            Thread.Sleep(300);
                            continue;
                        }
                        break;
                    }
                    int num5 = 0;
                    num5 = (int)fileStream.Length;
                    byte[] buffer = new byte[num5];
                    fileStream.Read(buffer, 0, num5);
                    fileStream.Close();
                    MemoryStream memoryStream = new MemoryStream(buffer);
                    image2 = Image.FromStream(memoryStream);
                    memoryStream.Flush();
                    Graphics graphics = Graphics.FromImage(image);
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.DrawImage(image2, new Rectangle(0, 0, image.Width, image.Height));
                }
            }
            else
            {
                MemoryStream memoryStream = new MemoryStream(array);
                image2 = Image.FromStream(memoryStream);
                memoryStream.Flush();
                Graphics graphics = Graphics.FromImage(image);
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.DrawImage(image2, new Rectangle(0, 0, image.Width, image.Height));
            }
            double num6 = 1.00001;
            double num7 = 1.00001;
            num6 = Math.Round(Convert.ToDouble(image.Width) / Convert.ToDouble(pictureBox.Width), 5);
            num7 = Math.Round(Convert.ToDouble(image.Height) / Convert.ToDouble(pictureBox.Height), 5);
            Point[] array2 = new Point[5];
            array2[0].X = Convert.ToInt32(Math.Floor((double)x10 * num6));
            array2[0].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array2[1].X = Convert.ToInt32(Math.Floor((double)x10 * num6));
            array2[1].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array2[2].X = Convert.ToInt32(Math.Floor((double)x11 * num6));
            array2[2].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array2[3].X = Convert.ToInt32(Math.Floor((double)x11 * num6));
            array2[3].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array2[4].X = Convert.ToInt32(Math.Floor((double)x10 * num6));
            array2[4].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            Point p = new Point(x, y);
            Font font = new Font("黑体", emsize, FontStyle.Bold);
            Brush brush = new SolidBrush(_mycolora);
            Pen pen = new Pen(_mycolorb, z_width);
            pen.DashStyle = (DashStyle)_myDashStyleType;
            Graphics graphics2 = Graphics.FromImage(image);
            graphics2.DrawLines(pen, array2);
            Point[] array3 = new Point[20];
            array3[0].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[0] * pictureBox.Width / 1000) * num6));
            array3[0].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[1].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[0] * pictureBox.Width / 1000) * num6));
            array3[1].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[2].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[1] * pictureBox.Width / 1000) * num6));
            array3[2].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[3].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[1] * pictureBox.Width / 1000) * num6));
            array3[3].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[4].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[2] * pictureBox.Width / 1000) * num6));
            array3[4].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[5].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[2] * pictureBox.Width / 1000) * num6));
            array3[5].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[6].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[3] * pictureBox.Width / 1000) * num6));
            array3[6].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[7].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[3] * pictureBox.Width / 1000) * num6));
            array3[7].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[8].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[4] * pictureBox.Width / 1000) * num6));
            array3[8].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[9].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[4] * pictureBox.Width / 1000) * num6));
            array3[9].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[10].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[5] * pictureBox.Width / 1000) * num6));
            array3[10].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[11].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[5] * pictureBox.Width / 1000) * num6));
            array3[11].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[12].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[6] * pictureBox.Width / 1000) * num6));
            array3[12].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[13].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[6] * pictureBox.Width / 1000) * num6));
            array3[13].Y = Convert.ToInt32(Math.Floor((double)(y11 * pictureBox.Height / 1000) * num7));
            array3[14].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[7] * pictureBox.Width / 1000) * num6));
            array3[14].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[15].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[7] * pictureBox.Width / 1000) * num6));
            array3[15].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[16].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[8] * pictureBox.Width / 1000) * num6));
            array3[16].Y = Convert.ToInt32(Math.Floor((double)(y10 * pictureBox.Height / 1000) * num7));
            array3[17].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[8] * pictureBox.Width / 1000) * num6));
            array3[17].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            array3[18].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[9] * pictureBox.Width / 1000) * num6));
            array3[18].Y = Convert.ToInt32(Math.Floor((double)y10 * num7));
            array3[19].X = Convert.ToInt32(Math.Floor((double)(XLAJIN[9] * pictureBox.Width / 1000) * num6));
            array3[19].Y = Convert.ToInt32(Math.Floor((double)y11 * num7));
            if (isshowlajin)
            {
                graphics2.DrawLine(pen, array3[0], array3[1]);
                graphics2.DrawLine(pen, array3[2], array3[3]);
                graphics2.DrawLine(pen, array3[4], array3[5]);
                graphics2.DrawLine(pen, array3[6], array3[7]);
                graphics2.DrawLine(pen, array3[8], array3[9]);
                graphics2.DrawLine(pen, array3[10], array3[11]);
                graphics2.DrawLine(pen, array3[12], array3[13]);
                graphics2.DrawLine(pen, array3[14], array3[15]);
                graphics2.DrawLine(pen, array3[16], array3[17]);
                graphics2.DrawLine(pen, array3[18], array3[19]);
            }
            Pen pen2 = new Pen(Color.AliceBlue, 1f);
            pen2.DashStyle = DashStyle.Dash;
            int num8 = 0;
            int num9 = 0;
            int num10 = 0;
            int num11 = 0;
            int num12 = 0;
            int num13 = 0;
            int num14 = 0;
            int num15 = 0;
            int num16 = 0;
            int num17 = 0;
            int num18 = 0;
            int num19 = 0;
            int num20 = 0;
            int num21 = 0;
            int num22 = 0;
            int num23 = 0;
            int num24 = 0;
            int num25 = 0;
            int num26 = 0;
            int num27 = 0;
            int num28 = 0;
            int num29 = 0;
            int num30 = 0;
            int num31 = 0;
            int num32 = 0;
            int num33 = 0;
            int num34 = 0;
            int num35 = 0;
            int num36 = Convert.ToInt32(Math.Floor((double)x10 * num6));
            int num37 = Convert.ToInt32(Math.Floor((double)x11 * num6));
            int num38 = Convert.ToInt32(Math.Floor((double)y10 * num7));
            int num39 = Convert.ToInt32(Math.Floor((double)y11 * num7));
            double d = num36 + (num37 - num36) / 6;
            double d2 = num36 + 2 * (num37 - num36) / 6;
            double d3 = num36 + 3 * (num37 - num36) / 6;
            double d4 = num36 + 4 * (num37 - num36) / 6;
            double d5 = num36 + 5 * (num37 - num36) / 6;
            double d6 = num38 + (num39 - num38) / 3;
            double d7 = num38 + 2 * (num39 - num38) / 3;
            num8 = Convert.ToInt32(Math.Floor(d));
            num9 = Convert.ToInt32(Math.Floor(d2));
            num10 = Convert.ToInt32(Math.Floor(d3));
            num11 = Convert.ToInt32(Math.Floor(d4));
            num12 = Convert.ToInt32(Math.Floor(d5));
            num22 = Convert.ToInt32(Math.Floor(d6));
            num23 = Convert.ToInt32(Math.Floor(d7));
            Point[] array4 = new Point[14];
            array4[0].X = num8;
            array4[0].Y = num38;
            array4[2].X = num9;
            array4[2].Y = num38;
            array4[4].X = num10;
            array4[4].Y = num38;
            array4[6].X = num11;
            array4[6].Y = num38;
            array4[8].X = num12;
            array4[8].Y = num38;
            array4[1].X = num8;
            array4[1].Y = num39;
            array4[3].X = num9;
            array4[3].Y = num39;
            array4[5].X = num10;
            array4[5].Y = num39;
            array4[7].X = num11;
            array4[7].Y = num39;
            array4[9].X = num12;
            array4[9].Y = num39;
            array4[10].X = num36;
            array4[10].Y = num22;
            array4[12].X = num36;
            array4[12].Y = num23;
            array4[11].X = num37;
            array4[11].Y = num22;
            array4[13].X = num37;
            array4[13].Y = num23;
            if (isshow18)
            {
                graphics2.DrawLine(pen2, array4[0], array4[1]);
                graphics2.DrawLine(pen2, array4[2], array4[3]);
                graphics2.DrawLine(pen2, array4[4], array4[5]);
                graphics2.DrawLine(pen2, array4[6], array4[7]);
                graphics2.DrawLine(pen2, array4[8], array4[9]);
                graphics2.DrawLine(pen2, array4[10], array4[11]);
                graphics2.DrawLine(pen2, array4[12], array4[13]);
            }
            if (mystr != null)
            {
                graphics2.DrawString(_str, font, brush, p);
                mycount++;
            }
            if (mycount > 30)
            {
                mystr = null;
                mycount = 0;
            }
            graphics2.SmoothingMode = SmoothingMode.HighQuality;
            for (int num4 = 0; num4 < 20; num4++)
            {
                graphics2.FillEllipse(new SolidBrush(rc[num4]), new Rectangle(Convert.ToInt32(Math.Floor((double)rx[num4] * num6)) - Convert.ToInt32(Math.Floor((double)r * num6)) / 2, Convert.ToInt32(Math.Floor((double)ry[num4] * num7)) - Convert.ToInt32(Math.Floor((double)r * num6)) / 2, Convert.ToInt32(Math.Floor((double)r * num6)), Convert.ToInt32(Math.Floor((double)r * num6))));
            }
            _bitmap = image;
            return num;
        }

        /// <summary>
        /// 连接摄像头
        /// </summary>
        /// <param name="address"></param>
        /// <param name="port"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        public uint DoConnect(string address, int port, string username, string password, int channel)
        {
            uint result = 0u;
            if (NetJudger.DoJudge(address))
            {
                mychanelA = channel;
                m_bInitSDK = NET_SDK.NET_DVR_Init();
                if (!m_bInitSDK)
                {
                    return 999u;
                }
                for (int i = 0; i < 64; i++)
                {
                    iIPDevID[i] = -1;
                    iChannelNum[i] = -1;
                }
                if (m_lUserID < 0)
                {
                    m_lUserID = NET_SDK.NET_DVR_Login_V30(address, port, username, password, ref DeviceInfo);
                    if (m_lUserID < 0)
                    {
                        return NET_SDK.NET_DVR_GetLastError();
                    }
                    dwAChanTotalNum = DeviceInfo.byChanNum;
                    if (DeviceInfo.byIPChanNum <= 0)
                    {
                        this.i = 0;
                        while (this.i < dwAChanTotalNum)
                        {
                            iChannelNum[this.i] = this.i + DeviceInfo.byStartChan;
                            this.i++;
                        }
                    }
                    if (m_lRealHandle < 0)
                    {
                        NET_SDK.NET_DVR_PREVIEWINFO lpPreviewInfo = default(NET_SDK.NET_DVR_PREVIEWINFO);
                        lpPreviewInfo.hPlayWnd = pictureBox.Handle;
                        lpPreviewInfo.lChannel = channel;
                        lpPreviewInfo.dwStreamType = 0u;
                        lpPreviewInfo.dwLinkMode = 0u;
                        lpPreviewInfo.bBlocked = true;
                        IntPtr zero = IntPtr.Zero;
                        m_lRealHandle = NET_SDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null, zero);
                        mydrawfun = cbDrawFun;
                        NET_SDK.NET_DVR_RigisterDrawFun(m_lRealHandle, mydrawfun, 0u);
                        if (m_lRealHandle < 0)
                        {
                            iLastErr = NET_SDK.NET_DVR_GetLastError();
                            return iLastErr;
                        }
                    }
                }
            }
            else
                FormHelper.ApplicationShow(UI.MsgType.Error, "画框摄像头网络中断.");
            return result;
        }

        public void DoClearScreen()
        {
            x10 = 0;
            y10 = 0;
            x11 = 0;
            y11 = 0;
            x0_old = 0;
            y0_old = 0;
            x1_old = 0;
            y1_old = 0;
            for (int i = 0; i < 10; i++)
            {
                XLAJIN[i] = -200;
            }
        }

        public void DoClearScreenrR()
        {
            for (int i = 0; i < rx.Length - 1; i++)
            {
                rx[i] = -200;
            }
            for (int i = 0; i < ry.Length - 1; i++)
            {
                ry[i] = 0;
            }
            r = 0;
        }

        private void myVideo_Resize(object sender, EventArgs e)
        {
            pictureBox.Top = 0;
            pictureBox.Left = 0;
            pictureBox.Width = base.Width;
            pictureBox.Height = base.Height;
        }

        private void myVideo_Load(object sender, EventArgs e)
        {
            pictureBox.Top = 0;
            pictureBox.Left = 0;
            pictureBox.Width = base.Width;
            pictureBox.Height = base.Height;
            for (int i = 0; i < rx.Length; i++)
            {
                rc[i] = Color.Red;
                rx[i] = -200;
            }
        }

        public void drawclicle(int[] x, int[] y, int myrr, Color[] myrc)
        {
            mystr = mystrr;
            for (int i = 0; i < x.Length; i++)
            {
                rx[i] = pictureBox.Width * x[i] / 1000;
                if (rx[i] == 0)
                {
                    rx[i] = -200;
                }
            }
            for (int i = 0; i < y.Length; i++)
            {
                ry[i] = pictureBox.Height * y[i] / 1000;
                rc[i] = myrc[i];
            }
            r = myrr;
        }

        public void drawclicle(int[] x, int[] y, int myrr, string[] myrc)
        {
            mystr = mystrr;
            for (int i = 0; i < x.Length; i++)
            {
                rx[i] = pictureBox.Width * x[i] / 1000;
                if (rx[i] == 0)
                {
                    rx[i] = -200;
                }
            }
            for (int i = 0; i < y.Length; i++)
            {
                ry[i] = pictureBox.Height * y[i] / 1000;
                if (myrc[i] != null)
                {
                    string[] array = myrc[i].Split(',');
                    rc[i] = Color.FromArgb(Convert.ToInt16(array[0]), Convert.ToInt16(array[1]), Convert.ToInt16(array[2]));
                }
            }
            r = myrr;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            emsize = 10 * pictureBox.Width / 320;
            z_width = zz_width;
        }

    }
}
